package com.syn.vr.repository;

import com.gaoyi.basemodule.baseCallback.Callback;
import com.gaoyi.basemodule.baseCallback.OnResultListener;
import com.gaoyi.basemodule.baseUtil.OKHttpUtil;

import java.lang.reflect.Type;

public class UserRepository {
    public void login(Object bean, OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/users/login", bean, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeofT);
    }

    public void forgotPwd(String email, OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().getAsync(OKHttpUtil.NET_URL + "/api/users/CheckEmail?eMail=" + email, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeofT);
    }

    public void resetPwd(Object bean, OnResultListener onResultListener, Type typeofT) {
        OKHttpUtil.getInstance().postAsync(OKHttpUtil.NET_URL + "/api/users/forgotPwdForEmail", bean, new Callback() {
            @Override
            public void onSuccess(Object obj) {
                onResultListener.onSuccess(obj);
            }

            @Override
            public void onFailed(Exception e) {
                onResultListener.onFails(e);
            }
        }, typeofT);
    }
}
